﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zocono.WCS.Infrastructure.PlcCommon;

namespace Zocono.WCS.Domain.PlcConnectPoolDomain
{
    public interface IPlcConnectionPoolService : IDomainService
    {
        /// <summary>
        /// 初始化加载所有PLC连接
        /// </summary>
        /// <param name="programeCode"></param>
        /// <returns></returns>
        Task S7LoadAllPlcConnection(string programeCode);

        /// <summary>
        /// 初始化加载所有PLC连接
        /// </summary>
        /// <param name="programeCodes"></param>
        /// <returns></returns>
        Task S7LoadAllPlcConnections(List<string> programeCodes);
        /// <summary>
        /// 定时加载已经释放的PLC连接
        /// </summary>
        /// <returns></returns>
        Task S7ReLoadPlcConnection();
        /// <summary>
        /// 按PlcConnectionID和JobName获取Plc连接，获取成功就锁定
        /// </summary>
        /// <param name="plcConnectionID"></param>
        /// <param name="jobName"></param>
        /// <returns></returns>
        PlcConnectionS7 S7GetReadPlcConnection(long plcConnectionID, string jobName,string  programe);
        bool S7LockJobReadPlcConnection(string jobName);
        /// <summary>
        /// 释放被锁定的PLC连接
        /// </summary>
        /// <param name="plcConnectionID"></param>
        /// <param name="jobName"></param>
        /// <returns></returns>
        bool S7FreeReadPlcConnection(long plcConnectionID, string jobName);
        /// <summary>
        /// 释放被锁定的PLC连接
        /// </summary>
        /// <param name="plcConnectionID"></param>
        /// <param name="jobName"></param>
        /// <returns></returns>
        bool S7FreeJobReadPlcConnection(string jobName,string programeCode);
        bool S7CheckJobLockedConnect(string jobName);
        /// <summary>
        /// 按PlcConnectionID获取Plc连接，不锁定
        /// </summary>
        /// <param name="plcConnectionID"></param>
        /// <returns></returns>
        PlcConnectionS7 S7GetWritePlcConnection(long plcConnectionID);
        Task S7Heartbeat();

        Task S7Heartbeat(List<string>   programe);

        PlcConnectionS7 S7GetReadPlcConnectionState(long plcConnectionID, string jobName, string programeCode);

    }
}
